package com.homegoods.orderinfodetail.model;

import android.os.Parcel;
import android.os.Parcelable;
import android.util.Log;

import com.alibaba.fastjson.JSON;

import java.io.Serializable;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;

/**
 * 必须实现 IModel
 * 可以根据不同的业务逻辑划分多个 Repository 类,多个业务逻辑相近的页面可以使用同一个 Repository 类
 * 无需每个页面都创建一个独立的 Repository
 */
public class OrderInfoDetailModel implements Serializable {
    /**
     * id : 132
     * supplierId : 19
     * shopId : 0
     * categoryId : 85
     * storageId : 22
     * productName : hua
     * pic : mall/images/20190710/1562728885357tDxRy2Qtz3kheykQRrCxDk4xQYPJKjX8.jpg
     * minPrice : 50
     * maxPrice : 50
     * point : 0
     * distributionType : true
     * ensure : [0,1,2]
     * address : 东城区
     * saleNum : 0
     * productDetailed : <html></html>
     * skuList : [{"id":289,"skuCode":"201907100132001","pic":"","salePrice":50,"stock":100,"attrs":[{"id":101,"attrValue":"白色"},{"id":102,"attrValue":"64"}]}]
     * categories : [{"id":101,"attrName":"颜色","values":["黑色","白色","红色","蓝色"]},{"id":102,"attrName":"内存版本","values":["32G","64","128","256","512"]}]
     * albumPics : ["mall/images/20190710/1562728676178MBH47iPRs8tPbGrNnmswZYHYFmtQ7eQS.jpg","mall/images/20190710/1562728888317y3kmBike8bNxtepYdfd4ARaybyQRt4fK.jpg"]
     */

    private int id;                                 //商品id
    private int supplierId;                         //供应商id
    private int shopId;                             //店铺id
    private int categoryId;                         //类目id
    private int storageId;                          //仓库id
    private String productName;                     //商品名称
    private String pic;                             //商品主图片
    private String minPrice;                    //最低价
    private BigDecimal maxPrice;                    //最高价
    private int point;                              //积分 (100积分 = 1元)
    private boolean distributionType;               //配送方式 false->运费设置 true->包邮
    private String address;                         //发货地址
    private int saleNum;                            //购买人数
    private String productDetailed;                 //商品详情Html
    private List<Integer> ensure;                   //保障权益(0 7天无理由退货 1 急速退款 2 正品保证)
    private List<SkuListBean> skuList;              //商品详情规格价格等信息
    private List<CategoriesBean> categories;        //选择规格
//    private List<String> albumPics;                 //轮播图
//    private List<ImageBean> albumPics;
    private String[] albumPics;

    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    public int getSupplierId() {
        return supplierId;
    }

    public void setSupplierId(int supplierId) {
        this.supplierId = supplierId;
    }

    public int getShopId() {
        return shopId;
    }

    public void setShopId(int shopId) {
        this.shopId = shopId;
    }

    public int getCategoryId() {
        return categoryId;
    }

    public void setCategoryId(int categoryId) {
        this.categoryId = categoryId;
    }

    public int getStorageId() {
        return storageId;
    }

    public void setStorageId(int storageId) {
        this.storageId = storageId;
    }

    public String getProductName() {
        return productName;
    }

    public void setProductName(String productName) {
        this.productName = productName;
    }

    public String getPic() {
        return pic;
    }

    public void setPic(String pic) {
        this.pic = pic;
    }

    public String getMinPrice() {
        return minPrice;
    }

    public void setMinPrice(String minPrice) {
        this.minPrice = minPrice;
    }

    public BigDecimal getMaxPrice() {
        return maxPrice;
    }

    public void setMaxPrice(BigDecimal maxPrice) {
        this.maxPrice = maxPrice;
    }

    public String getPoint() {
        return "可用" + point + "积分";
    }

    public void setPoint(int point) {
        this.point = point;
    }

    public String isDistributionType() {
        return distributionType ? "包邮" : "自费";
    }

    public void setDistributionType(boolean distributionType) {
        this.distributionType = distributionType;
    }

    public String getAddress() {
        return address;
    }

    public void setAddress(String address) {
        this.address = address;
    }

    public String getSaleNum() {
        return saleNum + " 人付款";
    }

    public void setSaleNum(int saleNum) {
        this.saleNum = saleNum;
    }

    public String getProductDetailed() {
        return productDetailed;
    }

    public void setProductDetailed(String productDetailed) {
        this.productDetailed = productDetailed;
    }

    public String getEnsure() {
        StringBuilder stringBuilder = new StringBuilder();
        String favorable = "";
        if (ensure == null) {
            return null;
        }
        for (int i = 0; i < ensure.size(); i++) {
            if (ensure.get(i) == 0) {
                favorable = "7天无理由退货";
            } else if (ensure.get(i) == 1) {
                favorable = "极速退款";
            } else if (ensure.get(i) == 2) {
                favorable = "正品保证";
            }
            stringBuilder.append(favorable).append(" ");
        }

        return String.valueOf(stringBuilder);
    }

    public void setEnsure(List<Integer> ensure) {
        this.ensure = ensure;
    }

    public List<SkuListBean> getSkuList() {
        return skuList;
    }

    public void setSkuList(List<SkuListBean> skuList) {
        this.skuList = skuList;
    }

    public List<CategoriesBean> getCategories() {
        return categories;
    }

    public void setCategories(List<CategoriesBean> categories) {
        this.categories = categories;
    }

    public String[] getAlbumPics() {
        return albumPics;
    }

    public void setAlbumPics(String[] albumPics) {
        this.albumPics = albumPics;
    }

    //    public List<String> getAlbumPic() {
//        return albumPics;
//    }

    @Override
    public String toString() {
        return "OrderInfoDetailModel{" + "id=" + id + ", supplierId=" + supplierId + ", shopId=" + shopId + ", categoryId=" + categoryId + ", storageId=" + storageId + ", productName='" + productName + '\'' + ", pic='" + pic + '\'' + ", minPrice=" + minPrice + ", maxPrice=" + maxPrice + ", point=" + point + ", distributionType=" + distributionType + ", address='" + address + '\'' + ", saleNum=" + saleNum + ", ensure=" + ensure + ", skuList=" + skuList + ", categories=" + categories + ", albumPics=" + albumPics + '}';
    }

//    public void setAlbumPic(List<String> albumPic) {
//        this.albumPics = albumPic;
//    }

//
//    public List<ImageBean> getAlbumPics() {
//        return albumPics;
//    }
//
//    public void setAlbumPics(List<ImageBean> albumPics) {
//        this.albumPics = albumPics;
//    }

    public static class SkuListBean implements Parcelable {
        /**
         * id : 289
         * skuCode : 201907100132001
         * pic :
         * salePrice : 50
         * stock : 100
         * attrs : [{"id":101,"attrValue":"白色"},{"id":102,"attrValue":"64"}]
         */

        private int id;                 //SKU id
        private String skuCode;         //商品Sku
        private String pic;             //该规格所呈现的小图 可能为空 如果为空 请缩放商品图片
        private BigDecimal salePrice;   //售价
        private int stock;              //库存
        private List<AttrsBean> attrs;  //Sku属性

        protected SkuListBean(Parcel in) {
            id = in.readInt();
            skuCode = in.readString();
            pic = in.readString();
            stock = in.readInt();
        }

        public SkuListBean() {
        }

        public static final Creator<SkuListBean> CREATOR = new Creator<SkuListBean>() {
            @Override
            public SkuListBean createFromParcel(Parcel in) {
                return new SkuListBean(in);
            }

            @Override
            public SkuListBean[] newArray(int size) {
                return new SkuListBean[size];
            }
        };

        public int getId() {
            return id;
        }

        public void setId(int id) {
            this.id = id;
        }

        public String getSkuCode() {
            return skuCode;
        }

        public void setSkuCode(String skuCode) {
            this.skuCode = skuCode;
        }

        public String getPic() {
            return pic;
        }

        public void setPic(String pic) {
            this.pic = pic;
        }

        public BigDecimal getSalePrice() {
            return salePrice;
        }

        public void setSalePrice(BigDecimal salePrice) {
            this.salePrice = salePrice;
        }

        public int getStock() {
            return stock;
        }

        public void setStock(int stock) {
            this.stock = stock;
        }

        public List<AttrsBean> getAttrs() {
            return attrs;
        }

        public void setAttrs(List<AttrsBean> attrs) {
            this.attrs = attrs;
        }

        @Override
        public int describeContents() {
            return 0;
        }

        @Override
        public void writeToParcel(Parcel dest, int flags) {
            dest.writeInt(id);
            dest.writeString(skuCode);
            dest.writeString(pic);
            dest.writeInt(stock);
        }

        public static class AttrsBean {
            /**
             * id : 101              //规格 id
             * attrValue : 白色       //规格值
             */

            private int id;             //规格 id
            private String attrValue;   //规格值

            public int getId() {
                return id;
            }

            public void setId(int id) {
                this.id = id;
            }

            public String getAttrValue() {
                return attrValue;
            }

            public void setAttrValue(String attrValue) {
                this.attrValue = attrValue;
            }
        }
    }

    public static class CategoriesBean implements Parcelable {
        /**
         * id : 101
         * attrName : 颜色
         * values : ["黑色","白色","红色","蓝色"]
         */

        private int id;                 //规格 id
        private String attrName;        //规格名
        private List<String> values;    //规格值
        private List<SKUValueModel> skuValues;//sku的value值，暂时这么写试一下（重新定义一个集合）

        protected CategoriesBean(Parcel in) {
            id = in.readInt();
            attrName = in.readString();
            values = in.createStringArrayList();
            skuValues = in.createTypedArrayList(SKUValueModel.CREATOR);
        }

        public static final Creator<CategoriesBean> CREATOR = new Creator<CategoriesBean>() {
            @Override
            public CategoriesBean createFromParcel(Parcel in) {
                return new CategoriesBean(in);
            }

            @Override
            public CategoriesBean[] newArray(int size) {
                return new CategoriesBean[size];
            }
        };

        public CategoriesBean() {
        }

        public List<SKUValueModel> getSkuValues() {
            List<SKUValueModel> list = new ArrayList<>();
            SKUValueModel skuValue = new SKUValueModel();
            for (int i = 0; i < values.size(); i++) {
                skuValue.setName(values.get(i));
                skuValue.setSuperName(attrName);
                list.add(skuValue);
            }
            skuValues = list;
            Log.d("zhengshibo", "getSkuValues: skuModel == " + JSON.toJSONString(skuValue));
            return skuValues;
        }

        public void setSkuValues(List<SKUValueModel> skuValues) {
            this.skuValues = skuValues;
        }

        public int getId() {
            return id;
        }

        public void setId(int id) {
            this.id = id;
        }

        public String getAttrName() {
            return attrName;
        }

        public void setAttrName(String attrName) {
            this.attrName = attrName;
        }

        public List<String> getValues() {
            return values;
        }

        public void setValues(List<String> values) {
            this.values = values;
        }

        @Override
        public int describeContents() {
            return 0;
        }

        @Override
        public void writeToParcel(Parcel dest, int flags) {
            dest.writeInt(id);
            dest.writeString(attrName);
            dest.writeStringList(values);
            dest.writeTypedList(skuValues);
        }
    }

    public static class ImageBean {
        private String image;

        public String getImage() {
            return image;
        }

        public void setImage(String image) {
            this.image = image;
        }
    }


    /**
     * 			"FixedParam": {
     * 				"品牌": "Daniel Wellington",
     * 				"型号": "Classic Petite Suffolk 28mm",
     * 				"形状": "圆形 ",
     * 				"成色": "全新",
     * 				"保修": "店铺保修",
     * 				"机芯类型": "石英机芯",
     * 				"表带材质": "皮革",
     * 				"表盘厚度": "6mm",
     * 				"颜色分类": "28mm Suffolk",
     * 				"表盘直径": "28mm",
     * 				"表壳材质": "不锈钢",
     * 				"上市时间": "2018年春季",
     * 				"显示方式": "指针式",
     * 				"手表种类": "女",
     * 				"表冠类型": "普通",
     * 				"auto16": "--",
     * 				"auto17": "--"
     *            },
     * 			"FloatParam": {
     * 				"颜色分类": "28mm Suffolk"
     *            },
     * 			"Comment": [],
     * 			"CommentCount": "0",
     * 			"Basicservelist": [{
     * 				"title": "15天无理由退货",
     * 				"intro": "15天无理由退货"
     *            }, {
     * 				"title": "99元免基础运费(20kg内)",
     * 				"intro": "99元免基础运费(20kg内)"
     *            }, {
     * 				"title": "先行赔付",
     * 				"intro": "先行赔付"
     *            }],
     * 			"GoodFeedBack": "0"
     */
    /*private String title;
    private String num;
    private String sid;
    private String SmallPic;
    private String Manufacturer;
    private String CmdtyService;
    private String SaleCount;
    private BigDecimal PayCake;
    private String CollectVol;
    private String StandardPrice;
    private BigDecimal NowPrice;
    private String Inventory;
    private String AboutInf;
    private String BuyUnit;
    private String BackCake;
    private String CollectStatu;
    private String DetailUrl;
    private String CommentCount;
    private String Comment;
    private String FloatParam;
    private String FixedParam;
    private List<ImgBean> ImgList;
    private String ListLabel;
    private InFoShop Businessman;
    private String Basicservelist;
    private String GoodFeedBack;

    public String getBackCake() {
        return BackCake;
    }

    public void setBackCake(String backCake) {
        BackCake = backCake;
    }

    public String getBasicservelist() {
        return Basicservelist;
    }

    public void setBasicservelist(String basicservelist) {
        Basicservelist = basicservelist;
    }

    public String getGoodFeedBack() {
        return GoodFeedBack;
    }

    public void setGoodFeedBack(String goodFeedBack) {
        GoodFeedBack = goodFeedBack;
    }

    public String getTitle() {
        return title;
    }

    public void setTitle(String title) {
        this.title = title;
    }

    public String getNum() {
        return num;
    }

    public void setNum(String num) {
        this.num = num;
    }

    public String getSid() {
        return sid;
    }

    public void setSid(String sid) {
        this.sid = sid;
    }

    public String getSmallPic() {
        return SmallPic;
    }

    public void setSmallPic(String smallPic) {
        SmallPic = smallPic;
    }

    public String getManufacturer() {
        return Manufacturer;
    }

    public void setManufacturer(String manufacturer) {
        Manufacturer = manufacturer;
    }

    public String getCmdtyService() {
        return CmdtyService;
    }

    public void setCmdtyService(String cmdtyService) {
        CmdtyService = cmdtyService;
    }

    public String getSaleCount() {
        return SaleCount;
    }

    public void setSaleCount(String saleCount) {
        SaleCount = saleCount;
    }

    public BigDecimal getPayCake() {
        return PayCake;
    }

    public void setPayCake(BigDecimal payCake) {
        PayCake = payCake;
    }

    public String getCollectVol() {
        return CollectVol;
    }

    public void setCollectVol(String collectVol) {
        CollectVol = collectVol;
    }

    public String getStandardPrice() {
        return StandardPrice;
    }

    public void setStandardPrice(String standardPrice) {
        StandardPrice = standardPrice;
    }

    public BigDecimal getNowPrice() {
        return NowPrice;
    }

    public void setNowPrice(BigDecimal nowPrice) {
        NowPrice = nowPrice;
    }

    public String getInventory() {
        return Inventory;
    }

    public void setInventory(String inventory) {
        Inventory = inventory;
    }

    public String getAboutInf() {
        return AboutInf;
    }

    public void setAboutInf(String aboutInf) {
        AboutInf = aboutInf;
    }

    public String getBuyUnit() {
        return BuyUnit;
    }

    public void setBuyUnit(String buyUnit) {
        BuyUnit = buyUnit;
    }

    public String getCollectStatu() {
        return CollectStatu;
    }

    public void setCollectStatu(String collectStatu) {
        CollectStatu = collectStatu;
    }

    public String getDetailUrl() {
        return DetailUrl;
    }

    public void setDetailUrl(String detailUrl) {
        DetailUrl = detailUrl;
    }

    public String getCommentCount() {
        return CommentCount;
    }

    public void setCommentCount(String commentCount) {
        CommentCount = commentCount;
    }

    public String getComment() {
        return Comment;
    }

    public void setComment(String comment) {
        Comment = comment;
    }

    public String getFloatParam() {
        return FloatParam;
    }

    public void setFloatParam(String floatParam) {
        FloatParam = floatParam;
    }

    public String getFixedParam() {
        return FixedParam;
    }

    public void setFixedParam(String fixedParam) {
        FixedParam = fixedParam;
    }

    public List<ImgBean> getImgList() {
        return ImgList;
    }

    public void setImgList(List<ImgBean> imgList) {
        ImgList = imgList;
    }

    public String getListLabel() {
        return ListLabel;
    }

    public void setListLabel(String listLabel) {
        ListLabel = listLabel;
    }

    public InFoShop getBusinessman() {
        return Businessman;
    }

    public void setBusinessman(InFoShop businessman) {
        Businessman = businessman;
    }

    public class InFoShop implements Serializable { //add implements shibo.zheng
        *//**
         * "title": "丹尼尔惠灵顿贸易(深圳)有限公司",
         *      * 				"sid": "factory_6a9bfeec5fd9425fa45834fba940a1c1",
         *      * 				"img": "/upath/2019/1/10/124648630109705ufi.jpg",
         *      * 				"intro": "（丹尼尔 · 惠灵顿）是一家源自北欧瑞典的手表品牌。 我公司于2011年成立，到现在仅仅三年已经卖出了超过一百万块手表，因此我们的品牌成为了当今全球发展最快的手表品牌之一。Daniel Wellington（丹尼尔 · 惠灵顿）每一个系列的手表款式都引领时尚风潮，且价格亲民 。我们怀揣梦想，希望把时尚元素传递到每个人身上。Daniel Wellington（丹尼尔 · 惠灵顿）是目前Instagram上面最大、粉丝活跃量最高的手表品牌，我们通过线上商店同时销往全球超过140个国家和地区。"
         *      *
         *//*
        private String title;
        private String img;
        private String sid;
        private String intro;

        public String getTitle() {
            return title;
        }

        public void setTitle(String title) {
            this.title = title;
        }

        public String getImg() {
            return img;
        }

        public void setImg(String img) {
            this.img = img;
        }

        public String getSid() {
            return sid;
        }

        public void setSid(String sid) {
            this.sid = sid;
        }

        public String getIntro() {
            return intro;
        }

        public void setIntro(String intro) {
            this.intro = intro;
        }
    }

    public class Basicserve implements Serializable {   //add implements shibo.zheng
        private String title;
        private String intro;

        public String getTitle() {
            return title;
        }

        public void setTitle(String title) {
            this.title = title;
        }

        public String getIntro() {
            return intro;
        }

        public void setIntro(String intro) {
            this.intro = intro;
        }
    }


    public class ImgBean implements Serializable{   //add implements shibo.zheng
        *//**
         * "url": "upath/2019/1/8/11538508693420ufi.jpg",
         * 				"name": "5b35f2d0f8055070c14a99f93673429.jpg",
         * 				"format": "image/jpeg",
         * 				"sid": "commodity_ab8af19750ef4d7684965e01c4431b5d",
         * 				"explain": "文件说明待完善"
         *//*
        private String url;
        private String name;
        private String format;
        private String sid;
        private String explain;

        public String getUrl() {
            return url;
        }

        public void setUrl(String url) {
            this.url = url;
        }

        public String getName() {
            return name;
        }

        public void setName(String name) {
            this.name = name;
        }

        public String getFormat() {
            return format;
        }

        public void setFormat(String format) {
            this.format = format;
        }

        public String getSid() {
            return sid;
        }

        public void setSid(String sid) {
            this.sid = sid;
        }

        public String getExplain() {
            return explain;
        }

        public void setExplain(String explain) {
            this.explain = explain;
        }
    }*/

}
